#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>

uint8_t LEDsendBuff[128] = {0};

void LED_Display_App(int Partition, unsigned char Color, char *Prefix_Char, int Width, char *Suffix_Char)
{
    uint8_t DisData[] = {0X97, 0X79, 0X00, 0X00, 0X00, 0x19, 0X01, 0X10,
                         0X00, 0X00, 0x00, 0x09, 0x12, 0X00, 0X00, 0X00,
                         0X00, 0X00, 0X12, 0X00, 0X47, 0X57, 0X31, 0X3A,
                         0X30, 0X30, 0X30, 0X2E, 0X30, 0X6D, 0X6D};

    // 分区
    DisData[14] = Partition;

    // 颜色
    DisData[20] = Color;

    // 前缀
    DisData[21] = Prefix_Char[0];
    DisData[22] = Prefix_Char[1];

    // 宽度
    sprintf(&DisData[24], "%03d.%01d", Width / 10, Width % 10);

    // 后缀
    DisData[29] = Suffix_Char[0];
    DisData[30] = Suffix_Char[1];

    // 复制到发送缓冲区
    memset(LEDsendBuff, 0x00, sizeof(LEDsendBuff));
    memcpy(LEDsendBuff, DisData, sizeof(DisData));
}

void Printf_Buf(uint8_t *data, uint16_t len)
{
    // 十六进制显示
    for (int i = 0; i < len; i++)
    {
        if (i % 16 == 0 && i != 0)
        {
            printf("\n");
        }

        printf("%02X ", data[i]);
    }
    printf("\n");

    // ASCII码显示
    for (int i = 0; i < len; i++)
    {
        printf("%c", data[i]);
    }
    printf("\n");
}

int main(void)
{
    LED_Display_App(0, 'G', "W1", 1800, "mm");

    Printf_Buf(LEDsendBuff, 31);

    uint8_t DisData[] = {0X97, 0X79, 0X00, 0X00, 0X00, 0x19, 0X01, 0X10,
                         0X00, 0X00, 0x00, 0x09, 0x12, 0X00, 0X00, 0X00,
                         0X00, 0X00, 0X12, 0X00, 0X47, 0X57, 0X31, 0X3A,
                         0X30, 0X30, 0X30, 0X2E, 0X30, 0X6D, 0X6D};

    Printf_Buf(DisData, sizeof(DisData));

    return 0;
}